#include <iostream>
#include <vector>
using namespace std;

/*int main() {
    string s;
    getline(cin, s);
    int n = s.size(), result = 0;
    vector<vector<bool>>dp(n, vector<bool>(n));
    for (int i = s.size() - 1; i >= 0; i--) {
        for (int j = i; j < s.size(); j++) {
            if (s[i] == s[j]) {
                if (j - i <= 1) {
                    dp[i][j] = true;
                    result++;
                } else if (dp[i + 1][j - 1] == true) {
                    dp[i][j] = true;
                    result++;
                }
            }
        }
    }
    cout << result << endl;
    return 0;
}*/

int getLongestPalindrome(string& A) {
    int n = A.size();
    int _max = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = n - 1; j >= 0; j--)
        {
            int l = i, r = j,count = 0;
            while (l <= r)
            {
                if (A[l] == A[r])
                {
                    if (l != r)
                        count += 2;
                    else
                        count++;
                    l++;
                }
                else
                {
                    count = 0;
                }
                r--;
            }
            _max = max(_max, count);
        }
    }
    return _max;
}

int main()
{
    string A = "baessdaba";
    cout << getLongestPalindrome(A) << endl;
    return 0;
}